<?php

#doc
#	classname:	JobController
#	scope:		PUBLIC
#
#/doc

class JobController extends Controller
{
	#	internal variables

	#	Constructor
	function __construct (  )
	{
		$this->useModel('job');
		Classloader::getInstance()->loadPlugin('Menu');
		Menu::getInstance()->addMenuEntry("Add", Utility::buildUrl("Job", "create"));
		Menu::getInstance()->addMenuEntry("List all", Utility::buildUrl("Job", "listAll"));
	}
	###

	public function listAll (  )
	{
		$this->jobs = $this->job->findAll();
	}

	public function show ()
	{
		$id = $_GET['id'];
		$this->job->find($id);
	}

	public function create( )
	{
		if(isset($_POST['name'])){
			$this->job->name = $_POST['name'];
			$this->job->description = $_POST['description'];
			$this->job->save();
			RoutingEngine::getInstance()->redirectToAction('job','show',$this->job->id);
			$this->flash('New customer created');
		}
	}

	public function install ( )
	{
		$this->job->createDatabaseTable();
	}

}
###

?>